<? /*
**************************************************
*	Crisses Mailinglist	       					 *
**************************************************
|                                                |
|   See install.txt for copyright & license info.|
-------------------------------------------------
*/ ?>
<?
include('config.php');
include('functions.php');


$language = "languages/".$language.".php";
include($language);



$phpversion = phpversion();

if(($phpversion > 4)&&($phpversion < 5)){	
	require('Swift/Swift.php');
	require('Swift/Swift/Swift_SMTP_Connection.php');
}elseif($phpversion >=5){
	require('Swift5/Swift.php');
	require('Swift5/Swift/Swift_SMTP_Connection.php');
}

$mail = new Swift(new Swift_SMTP_Connection($mailserver));
$key = randomkeys(32);

#error_reporting(0);
error_reporting(E_ALL ^ E_NOTICE);
/*
a
1 ->
2 ->
*/
$conn = mysql_connect($address, $username, $sql_password);
$query = $_SERVER['QUERY_STRING'];
$key = explode('=', $query);
$key = $key[1];




mysql_select_db($db, $conn)or die(mysql_error());


if((!isset($_POST[op]))&&(!isset($key))){
	$display_block = '
					  <table>
						<tr>
							<td><b>'.$l_mailinglist.'</b></td>
						</tr>
						<tr>
							<td><form action="'.$_SERVER['PHP_SELF'].'" METHOD="POST">
								<input type="text" name="email" size="'.$length.'" maxlength="'.$maxlength.'">
								<input type="hidden" name="op" value="set"><br/>
								<input type="radio" name="option" value="subscribe" CHECKED>'.$l_subscribe.'
								<input type="radio" name="option" value="unsubscribe">'.$l_unsubscribe.'<br/>
								<input type="submit" value="'.$l_submit.'" >
								</form><a href="http://code.google.com/p/crissesmailinglist/">Crisses Mailinglist</a>
							</td>
						</tr>
					</table>';
		
}elseif(($_POST[op] == 'set')&&($_POST[option] == 'subscribe')){

	$display_block = subscribe($_POST[email]);


}elseif(!empty($key)){

	echo activate($key);

}elseif(($_POST[op] == 'set')&&($_POST[option] == 'unsubscribe')){
	
	$display_block = unsubscribe($_POST[email]);
}

echo $display_block;

echo "<br/>".$sql;

?>
